// pages/info/info.js
let app=getApp();
Page({

    // 页面的初始数据
    data: {
        touxiang:null,
        imagurl:null,
        username:null,
        password:null,
        phone:null,
        city:null,
        banji:null,
        birth:null,
        xingbie:null,

    },
    //获取用户信息
    getuserinfo()
    {
        let that=this;
        // let phone=""+app.globalData.phone;
        // phone=phone.substring(0,3)+"****"+phone.substring(7,11);
        wx.request({
            url:app.globalData.url+'/getinfo', 
            header: { 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8' },
            data: {
                userid:app.globalData.openid,
             },
             method: 'post',
             success: function (res) {
                  that.setData({
            username:  res.data.username,
            password:res.data.password,
            city:res.data.city,
            phone:res.data.phone.substring(0,3)+"****"+res.data.phone.substring(7,11),
            banji:res.data.banji,
            birth:res.data.birth,
            imagurl:app.globalData.touxiang,
            xingbie:res.data.xingbie
             })
             },
             fail:function(err){//请求失败之后要做什么
                console.log('请求失败')
                }  
        })
       
    },
 //修改信息
        goupdate(e)
        {
            wx.navigateTo({
              url: '/pages/update/update?name='+e.currentTarget.dataset.name,
            })
        },
//返回个人中心
goback()
{
    wx.switchTab({
      url: '/pages/user/user',
    })
},
    // 生命周期函数--监听页面加载
    onLoad: function (options) {
        this.getuserinfo();
    },
})